package com.example.front.config;

import com.example.front.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration//表明是配配置类
public class MyWebConfig implements WebMvcConfigurer {

    @Autowired
    LoginInterceptor loginInterceptor;
    /**
     * 将自定义的拦截器进行注册
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
        //指定拦截那些路径
        .addPathPatterns("/*")
        //指定排除那些路径
        .excludePathPatterns("/user/login","/user/forget_get_question.do","/user/forget_check_answer.do","/user/adduser","/user/logout","/user/forget_reset_password.do");
    }
}
